/* -----------------------------------------------------------------------------
 * PROJECT    : net.lwf
 * FILE       : DigitValueAction.java
 *
 * HISTORY:
 * Date          Author                        Description
 * ----------------------------------------------------------------------------- 
 * Dec 2, 2008       Raghu Sarraff			       Created
 */
package net.lwf.web.struts.action.maths.number;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import lwf.handler.IProcessHandler;
import lwf.web.struts.action.constant.IActionConstant;
import net.lwf.entity.QuestionInfo;
import net.lwf.handler.math.number.DigitValueProcessHandler;
import net.lwf.web.constant.IPageTitle;
import net.lwf.web.struts.action.LwfWorksheetAction;
import net.lwf.web.struts.action.LwfWorksheetActionForm;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;


/**
 * Type the class description here
 *  
 */
public class DigitValueAction extends LwfWorksheetAction {
	
	public ActionForward generate(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		DigitValueProcessHandler handler = (DigitValueProcessHandler) getHandler(request);
		QuestionInfo qinfo = handler.generateSingle();
		//Set the question data
		setQuestionData(request, qinfo);
		//Set form data
		LwfWorksheetActionForm aform = (LwfWorksheetActionForm) form;
		aform.setQuestion(qinfo.getQuestion());
		aform.setAskQuestion(true);
		aform.setQuestionNumber(getQuestionNumber(request));
		aform.setInstructionText(qinfo.getPlaceHolder().toString());
		return mapping.findForward("display");
	}	
	
	@Override
	public String getPageTitle() {
		return IPageTitle.DIGIT_VALUE;
	}

	@Override
	public String getMainTitle() {
		return "Numbers";
	}

	@Override
	public String getPdfLink() {
		return IActionConstant.NUMBER_DIGITVALUE_PDF_LINK;
	}

	@Override
	public String getQuizLink() {
		return IActionConstant.NUMBER_DIGITVALUE_QUIZ_LINK;
	}
	
	@Override
	public IProcessHandler getHandler(HttpServletRequest request) {
		return new DigitValueProcessHandler();
	}

}

